package com.wk.code.wkserver.controller.admin;

import com.wk.code.wkserver.controller.common.BaseController;
import com.wk.code.wkserver.request.admin.AdminDemandRequest;
import com.wk.code.wkserver.request.admin.AdminSourceCodeRequest;
import com.wk.code.wkserver.request.admin.SourceCodeVerifyRequest;
import com.wk.code.wkserver.request.app.DemandVerifyRequest;
import com.wk.code.wkserver.response.admin.AdminSourceCodeDetailResponse;
import com.wk.code.wkserver.response.admin.DemandResponse;
import com.wk.code.wkserver.response.admin.SourceCodeResponse;
import com.wk.code.wkserver.response.app.SourceCodeDetailResponse;
import com.wk.code.wkserver.response.base.PageInfo;
import com.wk.code.wkserver.response.result.R;
import com.wk.code.wkserver.service.ISourceCodeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import lombok.AllArgsConstructor;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author wq
 * @since 2021-08-15
 */
@RestController
@RequestMapping("admin/sourceCode")
@AllArgsConstructor
@Api(tags = "admin-后台源码管理")
public class AdminSourceCodeController extends BaseController {

    final ISourceCodeService sourceCodeService;


    @ApiOperation(value = "系统源码分页列表")
    @PostMapping("/page")
    public R<PageInfo<SourceCodeResponse>> page(@RequestBody AdminSourceCodeRequest request) {
        return R.success(sourceCodeService.page(request));
    }


    /**
     * 审核源码
     *
     * @param request 请求参数
     * @return R
     */
    @ApiOperation(value = "审核源码")
    @PostMapping("/verify")
    public R<Void> verifyDemand(@RequestBody SourceCodeVerifyRequest request) {
        sourceCodeService.verifySourceCode(getSysUserId(), request);
        return R.success();
    }


    /**
     * 详情
     *
     * @param id ID
     * @return R
     */
    @ApiOperation(value = "详情")
    @GetMapping("/detail")
    public R<AdminSourceCodeDetailResponse> detail(Integer id) {
        return R.success(sourceCodeService.adminDetail(id));
    }


}
